package com.sbw.springboot.demo.async;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @Author: sangbowei
 * @Description: TODO
 * @Date: Created in  17:11 2017\12\23 0023
 **/
@Component
public class MsgServer {

    @Async
    public void sendA() throws InterruptedException {
        System.out.println("send A");
        Long startTime = System.currentTimeMillis();
        Thread.sleep(2000);
        Long endTime = System.currentTimeMillis();
        System.out.println("send A 耗时：" + (endTime - startTime));
    }

    @Async
    public void sendB() throws InterruptedException {
        System.out.println("send B");
        Long startTime = System.currentTimeMillis();
        Thread.sleep(3000);
        Long endTime = System.currentTimeMillis();
        System.out.println("send B 耗时：" + (endTime - startTime));
    }
}